<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>私有云平台</title>
	<meta charset="utf-8"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/public/bootstrap/css/bootstrap.css"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/public/bootstrap/css/bootstrap-responsive.css"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/css/jquery-ui-redmond/jquery-ui-1.8.21.custom.css">
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/css/global2.css">
	<script type="text/javascript" src="/EECloud/resource/jquery/jquery.js"></script>
    <script src="/EECloud/resource/public/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/EECloud/resource/jquery/jquery-ui-1.8.22.custom.min.js"></script>
    <script type="text/javascript">
    	$(document).ready(function(){
    		var menu_title = '<?=$menuTitle;?>';
    		$("#" + menu_title).addClass('active');

    	});
    </script>
	<style type="text/css">
		body{
			background-color: #EEE;
			height: 100%;
			width: 100%;
			margin: 0;
			padding: 0;
		}

		.hover{
			background-color:#A5C9E0;
		}

		.recycleHead{
			float:right;
			font-size: 13px;
			color: #5a5a5a;
			margin:15px;
		}

		.list-header{
			margin: 10px 60px 10px 55px;
			font-size: 13px;
		}
		.list-item-head{
			border: 1px solid #e5e5e5;
			clear: both;
			width: 90%;
			float: left;
			margin-left: 55px;
			line-height: 36px;
			background-color: #EEE;
			/*color: #e5e5e5;*/
		}
		.list-item{
			border-bottom: 1px solid #e5e5e5;
			clear: both;
			width: 90%;
			float: left;
			margin-left: 55px;
			line-height: 36px;
		}

		.chk-head{
			float: left;
			margin-left: 10px;
		}

		.chk{
			float: left;
			margin-left: 11px;
			/*margin-top: 5px;*/
		}
		.col{
			float: left;

		}
		
		.c2{
			border-left: 1px solid #e5e5e5;
			border-right: 1px solid #e5e5e5;
			/*padding-left: 8px;*/
		}
		.c3{
			/*padding-left: 8px;*/
			border-right: 1px solid #e5e5e5;
		}

		#container{
			/*position:absolute;left:0;right:0;top:0;bottom:0;*/
			height: 91%;
		}

		.row-fluid{
			height: 100%;
		}
		.span2{
			height: 100%;
			background-color:white;
		}
		.span10{
			height: 100%;
			background-color:white;
		}
	</style>
</head>
<body>
	<div class="container-fluid" style="min-width:1000px">
		<div class="navbar navbar-inverse">
			<div class="navbar-inner">
				<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	            </button>
	            <a class="brand" href="#"><img src="/EECloud/resource/img/pLogo.jpg" style="width:35px;height:25px">私有云平台</a>
	            <ul class="nav">
	            	<li class=""><a href="/EECloud/index.php/index">首页</a></li>
	            	<li><a href="/EECloud/index.php/pcloud">公共云</a></li>
	            	<li class="dropdown">
	            		<a class="dropdown-toggle" data-toggle="dropdown" href="">全部文件 <b class="caret"></b></a>
	            		<ul class="dropdown-menu">
	            			<li><a href="/EECloud/index.php/ring">全部文件</a></li>
	            			<li><a href="/EECloud/index.php/ring/files">文档</a></li>
	            			<li><a href="/EECloud/index.php/ring/images">图片</a></li>
	            			<li><a href="/EECloud/index.php/ring/vedios">视频</a></li>
	            			<li><a href="/EECloud/index.php/ring/music">音乐</a></li>
	            			<li><a href="/EECloud/index.php/ring/others">其他</a></li>
	            			<li class="divider"></li>
	            			<li><a href="/EECloud/index.php/ring/shares">我的分享</a></li>
	            			<li class="divider"></li>
	            			<li><a href="/EECloud/index.php/ring/recycleBin">我的回收站</a></li>
	            		</ul>
	            	</li>
	            </ul>
	            <ul class="nav" style="float:right;font-size:12px">
	            	<!-- <li>
	            		<form class="navbar-search">
						  <input type="text" class="search-query" placeholder="Search">
						  <a class="btn btn-small" style="margin-right:20px;margin-left:10px" href=""><i class="icon-search"></i> 搜索</a>
						</form>
	            	</li> -->
	            	<li><a href="/EECloud/index.php/userinfo"><i class="icon-user icon-white"></i> <?php echo $userName;?></a></li>
	            	<li><a href=""><i class="icon-envelope icon-white"></i> 通知</a></li>
	            	<li><a href="javascript:void(0);" id="returnIndex"><i class="icon-off icon-white"></i> 退出</a></li>
	            </ul>	
			</div>
		</div>
	</div>
	<div class="container-fluid" style="" id="container">
		<div class="row-fluid">
			<div class="span2" style="background-color:white">
				<ul class="nav nav-list">
					<li class="nav-header" style="font-size:20px">全部文件</li>
					<li class="divider"></li>
					<li id="allMenu"><a href="/EECloud/index.php/ring"><i class="icon-list-alt"></i> 全部文件</a></li>
					<li id="filesMenu"><a href="/EECloud/index.php/ring/files"><i class="icon-file"></i> 文档</a></li>
					<li id="imagesMenu"><a href="/EECloud/index.php/ring/images"><i class="icon-picture"></i> 图片</a></li>
					<li id="vediosMenu"><a href="/EECloud/index.php/ring/vedios"><i class="icon-film"></i> 视频</a></li>
					<li id="musicMenu"><a href="/EECloud/index.php/ring/music"><i class="icon-music"></i> 音乐</a></li>
					<li id="othersMenu"><a href="/EECloud/index.php/ring/others"><i class="icon-th-list"></i> 其他</a></li>
					<li class="divider"></li>
					<li id="sharesMenu"><a href="/EECloud/index.php/ring/shares"><i class="icon-share"></i> 我的分享</a></li>
					<li><a href="/EECloud/index.php/publishres/allres"><i class="icon-eye-open"></i> 资源审核</a></li>
					<li class="divider"></li>
					<li id="recycleMenu"><a href="/EECloud/index.php/ring/recycleBin"><i class="icon-trash"></i> 我的回收站</a></li>
				</ul>
			</div>
			<div class="span10" style="background-color:white;">
				<div class="recycleHead">提示：文件保存10天后将被服务器清除。&nbsp;&nbsp;
					<a href="javascript:void(0);" class="btn btn-danger" id="deleteRecycleBin"><i class="icon-trash icon-white"></i> 清空回收站</a>
				</div>
				<hr style="clear:both"/>
				<div>
					<div class="span12" style="">
						<div>
							<span  class="list-header" style="float:left">回收站</span><span class="list-header" style="float:right">已加载<?=$resourcesNum;?>项</span>
						</div>
						<div class="list-item-head">
							<div class="chk-head" style="width:5%" >
								<input type="checkbox" style="margin:auto;visibility:hidden" id="chkHead">
							</div>
							<div class="col c1" style="width:40%">文件名</div>
							<div class="col c2" style="width:15%;text-align:center">大小</div>
							<div class="col c3" style="width:20%;text-align:center">删除时间</div>
							<div class="col" style="width:15%;text-align:center">有效时间</div>
						</div>
						<?php if(!empty($records)) :?>
						<?php foreach ($records as $key => $val):?>
							<div class="list-item">
								<div class="chk" style="width:3%" name="chk"><input type="checkbox" style="margin:auto;cursor:default" name="chkItem" onclick="selectClick(this)"></div>
								<div class="col" style="width:36%"><a href="javascript:void(0);" title="<?=$val["resourceName"];?>"><?=$val["resourceName"];?></a>

								</div>
								<!-- <div class="col" style="width:3%;visibility:hidden" name="action"><a href="javascript:void(0);" class="download"><i class="icon-download" title="下载"></i></a></div> -->
								<div class="col" style="width:3%;visibility:hidden" name="action"><a href="javascript:void(0);" class="undo"><i class="icon-repeat" title="还原"></i></a></div>
								<div class="col" style="width:3%;visibility:hidden" name="action"><a href="javascript:void(0);" class="delteItem"><i class="icon-remove" title="彻底删除"></i></a></div>
								<div class="col" style="width:15%;text-align:center;padding-left"><?=$val['size'];?>K</div>
								<div class="col" style="width:20%;text-align:center;padding-left:10px"><?=$val['deleteTime'];?></div>
								<div class="col" style="width:15%;text-align:center;padding-left:">10天</div>
								<div class="col" style="visibility:hidden" name="rId" id="rId"><?=$val['id'];?></div>
							</div>
						<?php endforeach;?>
						<?php endif;?>
					</div>
					<?php echo $this->pagination->create_links();?>
				</div>

				<!-- 清空回收站窗口 -->
				<div id="deleteAllBox">
					<div>确定清空回收站？</div>
				</div>

				<div id="deleteBox">
					<div>确定彻底清除？</div>
				</div>

			</div>
		</div>
	</div>
	<script type="text/javascript">

		//resourceId里存入的是需要删除的文件的ID号
		var resourceId = [];
		//被删除项的ID
		var itemId = '';

		function selectClick(o){

			var idDiv = o.parentNode.parentNode.childNodes.item(15);

			Array.prototype.indexOf = function(val) {
	            for (var i = 0; i < this.length; i++) {
	                if (this[i] == val) return i;
	            }
	            return -1;
	        };
	        Array.prototype.remove = function(val) {
	            var index = this.indexOf(val);
	            if (index > -1) {
	                this.splice(index, 1);
	            }
	        };
			// a.style.cssText = 'border: 10px solid black';
			// alert(navigator.appName.indexOf('Explorer'));
			if(navigator.appName.indexOf('Explorer') > -1)  {
				if(o.checked){
					var action1 = o.parentNode.parentNode.childNodes.item(7);
					var action2 = o.parentNode.parentNode.childNodes.item(9);
					// var action3 = o.parentNode.parentNode.childNodes.item(9);
					action1.style.cssText = "width:3%";
					action2.style.cssText = "width:3%";
					// action3.style.cssText = "width:3%";
					resourceId.push(idDiv.innerText);
				}else{
					var action1 = o.parentNode.parentNode.childNodes.item(7);
					var action2 = o.parentNode.parentNode.childNodes.item(9);
					// var action3 = o.parentNode.parentNode.childNodes.item(9);
					action1.style.cssText = "width:3%;visibility:hidden";
					action2.style.cssText = "width:3%;visibility:hidden";
					// action3.style.cssText = "width:3%;visibility:hidden";
					resourceId.remove(idDiv.innerText);
				}    
			}else{
				if(o.checked){
					var action1 = o.parentNode.parentNode.childNodes.item(7);
					// alert(action1);
					var action2 = o.parentNode.parentNode.childNodes.item(9);
					action1.style.cssText = "width:3%";
					action2.style.cssText = "width:3%";
					// action3.style.cssText = "width:3%";
					resourceId.push(idDiv.textContent);
					// alert(resourceId);
				}else{
					var action1 = o.parentNode.parentNode.childNodes.item(7);
					var action2 = o.parentNode.parentNode.childNodes.item(9);
					// var action3 = o.parentNode.parentNode.childNodes.item(9);
					action1.style.cssText = "width:3%;visibility:hidden";
					action2.style.cssText = "width:3%;visibility:hidden";
					// action3.style.cssText = "width:3%;visibility:hidden";
					resourceId.remove(idDiv.textContent);
				} 
			} 
			
		}

		$("#deleteAllBox").dialog({
			autoOpen: false,
			height: 150,
			width: 250,
			modal: true,
			buttons: {
				"确定":function(){
					window.location.href = './delete_all_resource?userName=' + '<?=$userName;?>';
				},
				"取消":function(){
					$(this).dialog('close');
				}
			}
		});

		$("#deleteBox").dialog({
			autoOpen: false,
			height: 150,
			width: 250,
			modal: true,
			buttons: {
				"确定":function(){
					// alert(itemId);
					window.location.href = './delete_resource?rId=' + itemId;
				},
				"取消":function(){
					$(this).dialog('close');
				}
			}
		});

		$(document).ready(function(){

			var _height = window.screen.height-200;
			$('#container').css('height',_height);

			$(function(){
    			$('.list-item').mouseover(function(){
    				$(this).addClass("hover").siblings().removeClass("hover");
    			});
    		})

    		$(function(){
    			$('.list-item').mouseout(function(){
    				$(this).removeClass("hover");
    			});
    		})

    		$("#deleteRecycleBin").click(function(){
    			$("#deleteAllBox").dialog('open');
    		});

    		$(".delteItem").click(function(){
    			var index = $(this).parent().parent().children("div #rId").text();
    			itemId = index;
    			$("#deleteBox").dialog('open');
    		});

    		$("#deleteRecycleBin").click(function(){
    			$("deleteAllBox").dialog('open');
    		});

    		$(".undo").click(function(){
    			var index = $(this).parent().parent().children("div #rId").text();
    			itemId = index;
    			// alert(itemId);
    			$.post('/EECloud/index.php/ring/ajax_check_resource','rId=' + itemId,function(e){
    				if(!e.success){
    					alert("该文件已存在！");
    				}else{
    					window.location.href = './undo_resource?rId=' + itemId;
    				}
    			},'json');
    		});
		});
	</script>
</body>
</html>